/**
 * 查看方式
 * @param jobid
 */
var viewsign = true;
function to_view(jobid, type){
	if(type == 2){
		layer.confirm('你确定要投递这个简历吗？', {icon: 3, title: '先投递简历才能查看联系方式'}, function(index){
			if(viewsign){
				viewsign = false;
				$.ajax({
					url: '/personal/applyjob',
					dataType: "json",
					data: "jobid=" + jobid,
					type: "GET",
					success: function(data){
						switch(data.status){
							case 0:
								layer.msg(data.msg, {icon: 6});
								if(data.contact==''){
									$("#thShowContact").html('温馨提示:该企业暂不公开联系方式，只接受简历投递!');
								}else{
									$("#thShowContact").html(str_trim(data.contact.mobile + ' , ' + data.contact.phone, ','));
								}

								$("#showContantButton").remove();
								return true;
								break;
							case 1:
								layer.msg(data.msg, {icon: 5});
								break;
							case 2:
								layer.confirm(data.msg, {icon: 3, title: '查看联系方式'}, function(index){
									location.href = "/personal/my_resume";
									layer.close(index);
								});
								break;
							default:
								layer.msg(data.msg, {icon: 5, title: '查看联系方式'});
								break;
						}
					},
					error: function(data){
						var msgErr = '';
						var errors = $.parseJSON(data.responseText);
						$.each(errors, function(index, value){
							msgErr += value + ";<br>";
						});
						layer.msg(msgErr, {icon: 5});
					},
					complete: function(){
					}
				});
			}
			layer.close(index);
		});
	}else if(type == 3){
		layer.confirm('您的简历未通过审核或未创建，马上完善简历？', {icon: 3, title: '查看联系方式'}, function(index){
			location.href = '/personal/resume_mange';
			layer.close(index);
		});
	}
}

	/**
	 * 注册信息
	 */
	function dispense(){
		mobCodeUrl = '/personal/ajax_mob_code';
		//----------------------------------------------------------
		layer.open({
			type: 1,
			title: "此操作请先登录或注册",
			zIndex: 2,
			move: false,
			skin: 'layui-layer-rim', //加上边框
			area: ['840px', '650px'], //宽高
			content: '<div class="rightMain" style="padding:0px;"><div class="jobInfo resumeSend">' +
			'<div class="information"><span>HR心声：投递简历，可增加面试几率，获得高薪推荐！</span></div>' +
			'<form name="thisForm" onSubmit="return false" id="thisForm" method="post" >' +
			'<input name="_token" type="hidden" value="' + _token + '" />' +
			'<input name="id" type="hidden" value="" />' +
			'<dl><dt><span class="caption">手机号码</span><span class="asterisk">*</span></dt><dd>' +
			'<input type="text" name="mobile" id="mobile" value="" style="width: 268px;" placeholder="请输入手机号码" tip="请输入手机号码"/></dd><dd class="errinfo"></dd></dl>' +
			'<dl><dt><span class="caption">验证码</span><span class="asterisk">*</span></dt><dd>' +
			'<input type="text" name="mobCode" id="mobCode" value="" style="width: 130px;" placeholder="请输入验证码" tip="请输入验证码"/></dd>' +
			'<dd style="width: 130px; margin-right: 0px; display: block"><input name="mobcode" id="mobcode" type="button" onclick="personalRegGetMobileCode($(this),$(\'#mobile\'),imgCode,codeUrl,mobCodeUrl)" class="mobcode" value="点击获取验证码"></dd>' +
			'<dd class="errinfo"></dd></dl>' +
			'<dl><dt><span class="caption">姓名</span><span class="asterisk">*</span></dt><dd>' +
			'<input type="text" name="name" id="name"  style="width: 200px;"  placeholder="请输入姓名" tip="请输入姓名"/></dd><dd class="errinfo"></dd></dl>' +
			'<dl><dt><span class="caption">性别</span><span class="asterisk">*</span></dt>' +
			'<dd><span><input type="radio" name="sex" id="sex1" class="radios" checked value="1"/><label for="sex1">男</label>' +
			'</span><span class="mLeftTen"><input type="radio" name="sex" id="sex2" class="radios" value="2"/><label for="sex2">女</label></span></dd></dl>' +
			'<dl><dt><span class="caption">出生日期</span><span class="asterisk">*</span></dt>' +
			'<dd><div class="showTime" id="showTime"><input name="birthday" id="birthday" type="hidden" value=""></div></dd><dd class="errinfo"></dd></dl>' +
			'<dl><dt><span class="caption">学历</span><span class="asterisk">*</span></dt><dd><input id="education" style="height:35px;line-height:35px;" name="education" type="hidden" value="">' +
			'<div id="education_select" class="select" style="width: 160px;"><span><a></a></span><i></i></div></dd><dd class="errinfo"></dd></dl>' +
			'<dl><dt><span class="caption">岗位类别</span><span class="asterisk">*</span></dt>' +
			'<input name="jobsort1" type="hidden" id="jobsort1" value="">' +
			'<input name="jobsort2" type="hidden" id="jobsort2" value="">' +
			'<input name="jobsort3" type="hidden" id="jobsort3" value="">' +
			'<input name="jobsort4" type="hidden" id="jobsort4" value="">' +
			'<input name="jobsort5" type="hidden" id="jobsort5" value="">' +
			'<dd><span class="jList" id="posCateInput"><input type="text" name="jobsort" id="jobsort" value="" readonly="" style="cursor: text" placeholder="请选择工作岗位" class="valid"><i></i></span></dd><dd class="errinfo"></dd></dl>' +
			'<dl><dt><span class="caption">意向地区</span><span class="asterisk">*</span></dt>' +
			'<input name="jobarea1" type="hidden" id="jobarea1" value="">' +
			'<input name="jobarea2" type="hidden" id="jobarea2" value="">' +
			'<input name="jobarea3" type="hidden" id="jobarea3" value="">' +
			'<input name="jobarea4" type="hidden" id="jobarea4" value="">' +
			'<input name="jobarea5" type="hidden" id="jobarea5" value="">' +
			'<dd><span class="jList" id="workplaceInput"><input type="text" name="workplace" id="workplace" value="" readonly="" style="cursor: text" placeholder="请选择工作地区" class="valid"><i></i></span></dd><dd class="errinfo"></dd></dl>' +
			'<dl><dt><span class="caption">寻求职位</span><span class="asterisk">*</span></dt><dd>' +
			'<input type="text" name="intentionjobs" id="intentionjobs" value="" placeholder="请输入寻求职位" tip="请输入寻求职位"/></dd><dd class="errinfo"></dd></dl>' +
			'<dl  style="height: 60px;"><dt style="height:60px;"><span class="caption">自我评价</span></dt><dd>' +
			'<textarea style=" width: 394px; height: 48px;" name="introduction" id="introduction" placeholder="请输入自我评价" tip="请输入自我评价" aria-invalid="false" class="valid"></textarea></dd><dd class="errinfo"></dd></dl>' +
			'<dl style="margin-top:20px;"><dt></dt><dd><input name="sub" class="subs btn" type="submit" value="注册简历"></dd>' +
			'<dd style="margin-left:30px;"><span>如已有账户，点击此处<a style="color:#ff4400" onclick="haveLgoin()">立即登录</a></span></dd></dl>' +
			'</form></div></div>'
		});

		//学历
		$("#thisForm").find("#education").select({
			defaults: null,//默认按索引选中null为不选
			defaultFill: [{"value": '', "text": "请选择"}],//当defaults为null时,填空使用这个
			optionData: option_education
		});
		//日历时间
		$("#thisForm").find("#showTime").autoTime({
			year: "year",                               //弹出层年份
			month: "month",                             //弹出层月份
			established: '#birthday'                   //成立年份id
		});
		$("#thisForm").find("#workplaceInput").click(function(){
			workplaceInput('', 'type');
		});
		$("#thisForm").find("#posCateInput").click(function(){
			posCateInput('');
		});
		//个人会员手机号码验证
		$.validator.addMethod("checkMobile", function(value, element, param){
			var regu = /(^1[3-9]{1}[0-9]{9}$)/g;
			if(regu.test(value)){
				return true;
			}else{
				return false;
			}
		}, "请输入正确的手机号码");

		//表单验证 使用jQuery Validate 插件进行验证
		$('#thisForm').validate({
			//指定使用什么标签标记错误。
			errorElement: "span",
			//一个函数，可以自定义错误放到哪里。
			errorPlacement: function(error, element){
				$(element).parents('dl').find(".errinfo").append(error);
			},
			//自定义错误消息
			tipPlacement: function(element, tip){
				$(element).parents('dl').find(".errinfo").append(tip);
			},
			//通过验证后执行的函数
			success: function(label){
				if(label.parents('dl').find('dd input').val() != ''){
					label.text('ok!').addClass('success');
				}
			},
			//未验证后执行的函数
			highlight: function(element, errorClass){
				$(element).closest("dl").find("dd.errinfo").find('span').removeClass('success');
			},
			ignore: "",
			//js上面添加验证规则
			rules: {
				mobile: {
					required: true,
					minlength: 11,
					checkMobile: true //期望的是true,如果为false则展示提示信息
				},
				mobCode: {
					required: true,
					remote: {
						url: '/personal/ajax_sms_url',//后台处理程序
						type: "post",               //数据发送方式
						data: {                     //要传递的数据
							mobCode: function(){ return $("#mobCode").val();},
							mobile: function(){ return $("#mobile").val();},
							_token: _token
						},
						dataType: "html",
						dataFilter: function(data, type){
							return (data == "true") ? true : false;
						}
					}
				},
				name: {
					required: true
				},
				birthday: {
					required: true
				},
				education: {
					required: true
				},
				jobsort1: {
					required: true
				},
				jobarea1: {
					required: true
				},
				intentionjobs: {
					required: true
				}
			},
			//错误信息提示修改
			messages: {
				mobile: {
					required: "请输入手机号码",
					minlength: "手机号码长度必须是11位数字"
				},
				mobCode: {
					required: "请输入验证码",
					remote: $.validator.format('验证码错误，请重新输入')
				},
				name: {
					required: "请输入姓名"
				},
				birthday: {
					required: "请选择出生日期"
				},
				education: {
					required: "请选择学历"
				},
				jobsort1: {
					required: "请选择岗位类别"
				},
				jobarea1: {
					required: "请选择工作地区"
				},
				intentionjobs: {
					required: "请输入寻求职位"
				}
			},
			submitHandler: function(form){
				var queryString = $('#thisForm').formSerialize();
				$.ajax({
					url: '/personal/reg_info',
					dataType: "json",
					data: queryString,
					type: "POST",
					beforeSend: function(){
						$('#thisForm').find('.subs').val('请稍候');
						$('#thisForm').find('.subs').attr('disabled', true);
						$('#thisForm').find('.subs').attr('readonly', true);
					},
					success: function(data){
						if(data.status == 0){
							layer.closeAll();
							layer.open({
								type: 1,
								title: "注册成功",
								move: false,
								skin: 'layui-layer-rim', //加上边框
								area: ['640px', '500px'], //宽高
								content: '<div class="rightMain" style="padding:0px;width:640px;"><div class="jobInfo" style="width:560px;">' +
								'<div class="regsuccessinfo"><dt>恭喜您注册简历成功！以下是'+ data.webname +'为您生成的账号</dt>' +
								'<dd>请牢记：</dd>' +
								'<dd>您的用户名为：<strong>' + data.mobile + '</strong>临时密码：<strong>' + data.rand + '</strong></dd></dl></div>' +
								'<div class="information"><span>为了方便记忆，您可以马上修改密码！</span></div>' +
								'<form name="passwordForm" onSubmit="return false" id="passwordForm" method="post" >' +
								'<input name="uid" type="hidden" value="' + data.uid + '" />' +
								'<input name="_token" type="hidden" value="' + _token + '" />' +
								'<dl><dt><span class="caption">手机号码</span><span class="asterisk">*</span></dt><dd>' +
								'<input name="mobile" type="hidden" value="' + data.mobile + '" />' +
								'<input type="text" value="' + data.mobile + '" readonly="" style="background:#f1f1f1" /></dd><dd class="errinfo"></dd><dd class="errinfo">手机号码不能修改</dd></dl>' +
								'<dl><dt><span class="caption">新密码</span><span class="asterisk">*</span></dt><dd>' +
								'<input type="password" name="password" id="password" value=""  placeholder="请输入新密码" tip="请输入新密码"/></dd><dd class="errinfo"></dd></dl>' +
								'<dl><dt><span class="caption">确认密码</span><span class="asterisk">*</span></dt><dd>' +
								'<input type="password" name="password_confirmation" id="password_confirmation" value="" placeholder="请输入确认密码" tip="请输入确认密码"/></dd><dd class="errinfo"></dd></dl>' +
								'<dl style="margin-top:20px;"><dt></dt><dd><input name="sub" class="subs btn" type="submit" value="设置密码"></dd>' +
								'<dd style="margin-left:30px;"><span><a style="color:#ff4400" onclick="layer.closeAll();">跳过暂不修改</a></span></dd></dl>' +
								'</form></div></div>'
							});


							//表单验证 使用jQuery Validate 插件进行验证
							$('#passwordForm').validate({
								//指定使用什么标签标记错误。
								errorElement: "span",
								//一个函数，可以自定义错误放到哪里。
								errorPlacement: function(error, element){
									$(element).parents('dl').find(".errinfo").append(error);
								},
								//自定义错误消息
								tipPlacement: function(element, tip){
									$(element).parents('dl').find(".errinfo").append(tip);
								},
								//通过验证后执行的函数
								success: function(label){
									if(label.parents('dl').find('dd input').val() != ''){
										label.text('ok!').addClass('success');
									}
								},
								//未验证后执行的函数
								highlight: function(element, errorClass){
									$(element).closest("dl").find("dd.errinfo").find('span').removeClass('success');
								},
								ignore: "",
								//js上面添加验证规则
								rules: {
									password: {
										required: true,
										minlength: 6
									},
									password_confirmation: {
										required: true,
										minlength: 6,
										equalTo: "#password"
									}
								},
								//错误信息提示修改
								messages: {
									password: {
										required: "请输入新密码",
										minlength: "新密码长度不能小于6个字符"
									},
									password_confirmation: {
										required: "请输入确认密码",
										minlength: "确认密码长度不能小于6个字符",
										equalTo: "两次密码输入不一致"
									}
								},
								submitHandler: function(form){
									var queryString = $('#passwordForm').formSerialize();
									$.ajax({
										url: '/personal/post_password_two',
										dataType: "json",
										data: queryString,
										type: "POST",
										beforeSend: function(){
											$('#passwordForm').find('.subs').val('请稍候');
											$('#passwordForm').find('.subs').attr('disabled', true);
											$('#passwordForm').find('.subs').attr('readonly', true);
										},
										success: function(data){
											layer.closeAll();
											layer.open({
												type: 1,
												title: "已完成微简历注册",
												move: false,
												skin: 'layui-layer-rim', //加上边框
												area: ['640px', '400px'], //宽高
												content: '<div class="rightMain" style="padding:0px;width:640px;"><div class="jobInfo" style="width:560px;">' +
												'<div class="regsuccessinfo"><dt>恭喜您修改密码成功！以下是您的用户名和密码</dt>' +
												'<dd>请牢记：</dd>' +
												'<dd>您的用户名为：<strong>' + data.mobile + '</strong>密码：<strong>' + data.password + '</strong></dd></dl></div>' +
												'<div class="information"><span>建议填写一份完整的简历，找一份好工作,一份好简历必不可少！</span></div>' +
												'<div class="fillin"><span><a href="/personal/resume_mange" class="immediately">马上填写</a></span>' +
												'<span class="microresume"><a style="color:#ff4400" onclick="layer.closeAll();">微简历够用了 以后再说!</a></span></div>' +
												'</div></div>'
											})
											;
										},
										error: function(data){
											var msgErr = '';
											var errors = $.parseJSON(data.responseText);
											$.each(errors, function(index, value){
												msgErr += value + ";<br>";
											});
											layer.msg(msgErr);
										},
										complete: function(){
											$('#passwordForm').find('.subs').val('保存');
											$('#passwordForm').find('.subs').removeAttr('disabled');
											$('#passwordForm').find('.subs').removeAttr('readonly');
										}
									});
								}
							});
						}else{
							layer.msg(data.msg, {time: 2000});
						}
					},
					error: function(data){
						var msgErr = '';
						var errors = $.parseJSON(data.responseText);
						$.each(errors, function(index, value){
							msgErr += value + ";<br>";
						});
						layer.msg(msgErr);
					},
					complete: function(){
						$('#thisForm').find('.subs').val('保存');
						$('#thisForm').find('.subs').removeAttr('disabled');
						$('#thisForm').find('.subs').removeAttr('readonly');
					}
				});
			}
		});
		//-------------------------------------
	}